﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.InputSystem;


[CreateAssetMenu(menuName = "Story Input")]
public class StoryInput : ScriptableObject, InputActions.IStoryPlayingActions
{
    InputActions inputActions;

    //各种事件
    public event UnityAction onStoryPlay;

    void OnEnable()
    {
        inputActions = new InputActions();
        inputActions.StoryPlaying.SetCallbacks(this);
    }
    void OnDisable()
    {
        DisableAllInputs();
    }

    /*******************************************/
    //以下为激活对应动作表的方法
    /*******************************************/
    /*
    public void EnableGameplayInput()//作为笔记，无用代码
    {
        inputActions.Gameplay.Enable();//激活对应的动作表

        Cursor.visible = false;//隐藏鼠标显示
        Cursor.lockState = CursorLockMode.Locked;//锁定鼠标移动
    }
    */
    public void DisableAllInputs()//关闭所有的动作表
    {
        //Debug.Log("关闭所有动作表");
        inputActions.StoryPlaying.Disable();
        Cursor.lockState = CursorLockMode.None;
    }

    public void EnableStoryPlaying()//播放剧情时使用
    {
        inputActions.StoryPlaying.Enable();

        //Cursor.visible = false;//隐藏鼠标显示
        Cursor.lockState = CursorLockMode.Locked;//锁定鼠标移动
    }

    


    /*******************************************/
    //以下为
    /*******************************************/
    public void OnStoryPlay(InputAction.CallbackContext context)
    {
        if(context.phase == InputActionPhase.Performed)
        {
            if (onStoryPlay != null)
                onStoryPlay.Invoke();
        }
    }
}
